package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.QdepFrom;
import cn.gson.fengboot.model.pojos.QdepFromBo;
import cn.gson.fengboot.model.pojos.QroleFromBo;
import cn.gson.fengboot.model.service.DdepService;
import cn.gson.fengboot.model.service.DmenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/myjurisdiction")
public class DdepController {

    @Autowired
    DdepService service;

    @Autowired
    DmenusService dmenusService;

    /*部门查询*/
    /*岗位*/
    /*查询我所有的权限菜单*/
    @RequestMapping("/selectmyalldep")
    public Map<String,Object> selectmyalldep() throws Exception {
        Map<String,Object> map = new HashMap<>();
        map.put("mydepqx",service.getLeftTrees());//部门无限极
        map.put("myroleqx",service.getLeftRoleTrees());//岗位无限极
        map.put("myallrole",dmenusService.myallmenus());/*查询我所有的权限菜单*/

        return map;
    }


    /*岗位*/
    @RequestMapping("/getLeftRoleTrees")
    public List<QroleFromBo> getLeftRoleTrees() throws Exception {
        return service.getLeftRoleTrees();
    }

    /*新增部门*/
    @RequestMapping("/savemydep")
    public void savemydep(@RequestBody QdepFrom qdepFrom){
        service.savemydep(qdepFrom);
    }

    /*验证部门是否可删除*/
    @RequestMapping("/verifyisempty")
    public Integer verifyisempty(Integer depId){
        return service.verifyisempty(depId);
    }


    /*根据部门id组查询部门名称*/
    @RequestMapping("/selectdepbydeparr")
    public String selectbymydepid(String deparr){
        return service.selectbymydepid(deparr);
    }




}
